package com.project.web.admin.controller.app;

import com.project.common.core.utils.exception.Result;
import com.project.web.admin.controller.common.BaseController;
import com.project.web.feign.UserClient;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * 登录服务控制器
 *
 * @author wyy
 * @date 2019-09-17
 */
@Api(value = "登录服务", tags = "登录服务")
@RestController("adminLoginController")
@RequestMapping("/admin/anon")
public class LoginController extends BaseController {

    @Autowired
    public UserClient userClient;

    /**
     * 登录接口
     *
     * @param phone 手机号
     * @return
     */
    @ApiOperation(value = "登录接口", notes = "登录接口", httpMethod = "POST")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "phone", value = "手机号", dataType = "String")
    })
    @PostMapping(value = "/login")
    public Result<String> test(String phone) {
        // API服务内调用查询用户
        Map<String, Object> byPhone = userClient.getByPhone(phone);

        return getResult(byPhone);
    }
}
